<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center myCoupon_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub myCoupon_fd0_0'>
					<view class='flex flex-wrap align-center myCoupon_fd0_0_c0' @tap="handleJumpDiy" data-type="back"
						data-url="1">
						<text class='fu-iconfont2  myCoupon_fd0_0_c0_c0'>&#xe794;</text>
					</view>
					<text class='myCoupon_fd0_0_c1'>我的优惠券</text>
					<view class='flex flex-wrap align-center myCoupon_fd0_0_c0'>
					</view>
				</view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex myCoupon_flex_1"
				:style="{top:(88+StatusBarRpx)+'rpx', }">
				<view>
					<benben-flex-tabs class-name='myCoupon_benbenTabsfd1_0' v-model="type" ref="benben_tabsfd1_0"
						select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false'
						:open-sticky='true' :top='0' :is-show-content='false' :scrollspy='false'
						:tabs-info.sync="tabsInfofd1_0" @change="getCouponFunc()">
						<scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
							class="benben-tabs" style="width:750rpx" :scroll-x="true"
							:scroll-left.sync="tabsInfofd1_0.moveX" scroll-with-animation="all .3s ease">
							<view class="benben-tabs-content" id="benben_tabsfd1_0-content">
								<view id="benben_tabsfd1_0-title"
									class="benben-tabs-title flex flex align-center justify-around">
									<view
										:class="{ 'checkTitlefd1_0': type == '2', 'flex flex-wrap align-center': true }"
										@tap="type = '2'" :id="`benben_tabsfd1_0-title-item-${'2'}`">

										<text>可使用优惠券</text>

										<text>(</text>

										<text>{{headData.available_num}}</text>

										<text>)</text>

									</view>
									<view
										:class="{ 'checkTitlefd1_0': type == '5', 'flex flex-wrap align-center': true }"
										@tap="type = '5'" :id="`benben_tabsfd1_0-title-item-${'5'}`">

										<text>不可使用优惠券</text>

										<text>(</text>

										<text>{{headData.noavailable_num}}</text>

										<text>)</text>

									</view>
								</view>
								<view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
									id="benben_tabsfd1_0-line"
									class="benben-tabs-line flex benben-flex-tabs-line myCoupon_linefd1_0"></view>
							</view>
						</scroll-view>

					</benben-flex-tabs>

				</view>
				<view class='flex flex-wrap align-center myCoupon_fd1_1'>
					<view class='flex flex-wrap align-center myCoupon_fd1_1_c0'>
						<benben-input class='flex-sub myCoupon_fd1_1_c0_c0' type="text" :placeholder="`请输入兑换码`"
							confirm-type="done" :maxlength="50" placeholder-style="color:#999;font-size:28rpx"
							v-model="coupon_code" />
						<button class='myCoupon_fd1_1_c0_c1' @tap="getExchangeFunc()">兑换</button>
					</view>
				</view>

			</view>
			<view :style="{height: '200rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout myCoupon_flex_2">
				<template v-for='(item,key0) in couponList'>
					<view class='flex flex-direction flex-wrap align-stretch' :key='key0'>
						<view class='flex flex-wrap align-center myCoupon_fd2_0_c0' v-if="item.status=='1'">
							<view
								class='flex flex-direction flex-wrap align-center justify-center myCoupon_fd2_0_c0_c0'>
								<view class='flex align-center'>
									<text class='myCoupon_fd2_0_c0_c0_c0_c0'>￥</text>
									<text class='myCoupon_fd2_0_c0_c0_c0_c1'>{{item.money}}</text>
								</view>
								<text class='myCoupon_fd2_0_c0_c0_c1'>{{item.min_conten}}</text>
							</view>
							<view
								class='flex flex-direction flex-wrap align-stretch justify-center flex-sub myCoupon_fd2_0_c0_c1'>
								<text class='myCoupon_fd2_0_c0_c1_c0'>{{item.coupon_name}}</text>
								<text class='myCoupon_fd2_0_c0_c1_c1'>{{item.content}}</text>
								<text class='myCoupon_fd2_0_c0_c1_c1001'
									v-if="item.store_name !=''">{{item.store_name}}</text>
								<view class='flex flex-wrap align-center myCoupon_fd2_0_c0_c1_c2'>
									<text class='myCoupon_fd2_0_c0_c1_c2_c0'>有效期至：</text>
									<text class='myCoupon_fd2_0_c0_c1_c2_c0'>{{item.end_time}}</text>
								</view>
							</view>
						</view>
						<view class='flex flex-wrap align-center myCoupon_fd2_0_c1' v-if="item.status>'2'">
							<view
								class='flex flex-direction flex-wrap align-center justify-center myCoupon_fd2_0_c0_c0'>
								<view class='flex align-center'>
									<text class='myCoupon_fd2_0_c0_c0_c0_c0'>￥</text>
									<text class='myCoupon_fd2_0_c0_c0_c0_c1'>{{item.money}}</text>
								</view>
								<text class='myCoupon_fd2_0_c0_c0_c1'>{{item.min_conten}}</text>
							</view>
							<view
								class='flex flex-direction flex-wrap align-stretch justify-center flex-sub myCoupon_fd2_0_c0_c1'>
								<view class='flex flex-wrap align-center justify-between'>
									<text class='flex-sub myCoupon_fd2_0_c0_c1_c0'>{{item.coupon_name}}</text>
									<text class='myCoupon_fd2_0_c1_c1_c0_c1'>{{item.status_name}}</text>
								</view>
								<text class='myCoupon_fd2_0_c0_c1_c1'>{{item.content}}</text>
								<text class='myCoupon_fd2_0_c0_c1_c1001'
									v-if="item.store_name !=''">{{item.store_name}}</text>
								<view class='flex flex-wrap align-center myCoupon_fd2_0_c0_c1_c2'>
									<text class='myCoupon_fd2_0_c0_c1_c2_c0'>有效期至：</text>
									<text class='myCoupon_fd2_0_c0_c1_c2_c0'>{{item.end_time}}</text>
								</view>
							</view>
						</view>
					</view>
				</template>
				<fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
					:listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0
				},
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"couponList": [],
				"headData": {
					"available_num": "",
					"noavailable_num": ""
				},
				"coupon_code": "",
				"type": "2",
				"coupon_type": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				coupon_type
			} = options
			if (coupon_type !== undefined) this.coupon_type = coupon_type
			this.getCouponFunc()
			this.getNumFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.getCouponFunc()
			this.getNumFunc()
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取优惠券信息
			getCouponFunc() {
				this.minixPagingListsApi = global.apiUrls.post64198610a95ca;
				this.pageingListApiMethod = 'post';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {
					type: this.type,
					coupon_type: this.coupon_type
				}
				this.listData = [];
				this.couponList = this.listData;
				this.pagingListToggle();

			},
			//获取优惠券头部数量
			async getNumFunc() {
				//请求方法
				//数据验证

				let dataheadData = await this.$api.get(global.apiUrls.post64dedd6614c78, {
					coupon_type: this.coupon_type
				});

				if (dataheadData.data.code != 1) {
					this.$message.info(dataheadData.data.msg);
					return
				}
				let infoheadData = dataheadData.data;
				this.headData = infoheadData.data

			},
			//提交兑换码
			async getExchangeFunc() {
				if (!validate(this.coupon_code, 'require')) {
					this.$message.info('兑换码不能为空');
					return false;
				}
				//请求方法
				//数据验证

				let data64dedc85c1e82 = await this.$api.dbPost(global.apiUrls.post64dedc85c1e82, {
					coupon_code: this.coupon_code,
					coupon_type: this.coupon_type
				});
				if (!data64dedc85c1e82) return
				if (data64dedc85c1e82.data.code != 1) {
					this.$message.info(data64dedc85c1e82.data.msg);
					return
				} else {
					this.$message.info(data64dedc85c1e82.data.msg);
				}
				this.getCouponFunc()
				this.getNumFunc()
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(255, 255, 255, 1);
		background-size: 100% auto;
	}

	.myCoupon_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.myCoupon_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.myCoupon_fd0_0_c0_c0 {
		font-size: 32rpx;
		color: #333;
	}

	.myCoupon_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.myCoupon_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.myCoupon_flex_1 {
		background: rgba(255, 255, 255, 1);
		width: 750rpx;
		height: 200rpx;
		overflow: hidden;
		z-index: 10;
		top: 88rpx;
		background-size: 100% auto;
	}

	.myCoupon_fd1_1_c0_c1 {
		background: var(--benbenbgColor2);
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 160rpx;
		line-height: 60rpx;
		font-size: 24rpx;
		color: #fff;
		height: 62rpx;
	}

	.myCoupon_fd1_1_c0_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		margin: 8rpx 24rpx 0rpx 40rpx;
	}

	.myCoupon_fd1_1_c0 {
		border: 1px solid var(--benbenbdColor2);
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 686rpx;
		height: 72rpx;
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.myCoupon_fd1_1 {
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.myCoupon_linefd1_0 {
		background: var(--benbenbgColor2);
		width: 40rpx;
		height: 6rpx;
		top: 80rpx;
		background-size: 100% auto !important;
	}

	.checkTitlefd1_0 {
		font-weight: 700 !important;
		font-size: 32rpx !important;
		color: #333 !important;
		background-color: rgba(255, 255, 255, 0) !important;
	}

	::v-deep .myCoupon_benbenTabsfd1_0 {
		width: 750rpx;
		height: 91rpx;
		white-space: nowrap;
		text-align: center;
		font-size: 32rpx;
		font-weight: 400;
		color: #666666;
	}

	.myCoupon_flex_2 {
		padding: 32rpx 32rpx 0rpx 32rpx;
	}

	.myCoupon_fd2_0_c1_c1_c0_c1 {
		color: rgba(153, 153, 153, 1);
	}

	.myCoupon_fd2_0_c1 {
		background: url(image-path('334.png')) no-repeat;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0rpx 0rpx 20rpx 0rpx;
		box-shadow: 4rpx 8rpx 12rpx rgba(51, 51, 51, 0.06);
	}

	.myCoupon_fd2_0_c0_c1_c2_c0 {
		color: #666666;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 30rpx;
	}

	.myCoupon_fd2_0_c0_c1_c2 {
		color: #909093;
		font-size: 22rpx;
		line-height: 30rpx;
		font-weight: 400;
	}

	.myCoupon_fd2_0_c0_c1_c1 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 16rpx 0rpx 16rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myCoupon_fd2_0_c0_c1_c1001 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 0rpx 0rpx 16rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myCoupon_fd2_0_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 700;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 40rpx;
	}

	.myCoupon_fd2_0_c0_c1 {
		height: 190rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.myCoupon_fd2_0_c0_c0_c1 {
		color: #FFFFFF;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 33rpx;
		margin: 7rpx 0rpx 0rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myCoupon_fd2_0_c0_c0_c0_c1 {
		color: #FFFFFF;
		font-size: 42rpx;
		font-weight: 700;
		line-height: 67rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.myCoupon_fd2_0_c0_c0_c0_c0 {
		color: #FFFFFF;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 32rpx;
		margin: 13rpx 0rpx 0rpx 0rpx;
	}

	.myCoupon_fd2_0_c0_c0 {
		width: 190rpx;
		height: 190rpx;
	}

	.myCoupon_fd2_0_c0 {
		background: url(image-path('333.png')) no-repeat;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0rpx 0rpx 20rpx 0rpx;
		box-shadow: 4rpx 8rpx 12rpx rgba(51, 51, 51, 0.06);
	}
</style>